/**
 * Created by 2006-1-19 17:18:51
 * $Id: UserManager.java 82 2006-07-10 10:12:42Z wjx $
 */
package com.someok.security.service;

import java.util.Date;
import java.util.List;

import com.someok.base.common.BaseDAOSupport;
import com.someok.security.model.User;

/**
 * 
 *
 * <p><a href="UserManager.java.html"><i>View Source</i></a></p>
 *
 * @author wjx
 * @version $Revision: 82 $ $Date: 2006-07-10 18:12:42 +0800 (星期一, 10 七月 2006) $
 */
public class UserManager extends BaseDAOSupport {

	protected Class getEntityClass() {
		return User.class;
	}

	public User getUser(User user) {
		return (User) get(user.getId());
	}

	public User getUser(String id) {
		return (User) get(id);
	}

	public List getAllUsers() {
		return getAll();
	}

	/**
	 * 创建新的User.
	 */
	public void insertUser(User user) {
		// 初始化User的创建时间和修改时间
		user.setCreateTime(new Date());
		user.setModifyTime(new Date());

		getHibernateTemplate().save(user);
		// getHibernateTemplate().flush();
	}

	public void updateUser(User user) {
		user.setModifyTime(new Date());

		getHibernateTemplate().update(user);
	}

	public void deleteUser(String id) {
		delete(id);
	}

}
